package com.cssiot.scala.controller

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.servlet.ModelAndView
import org.springframework.web.bind.annotation.RequestMethod
import java.util.Date
import org.springframework.ui.Model
import javax.servlet.http.HttpServletResponse
import java.io.Writer
import javax.servlet.http.HttpServletRequest

@RestController
@RequestMapping(Array("/hello"))
class HelloController {

  @RequestMapping(Array("", "/"))
//   @RequestMapping(Array("", "/"))
  def greeting( model:Model, request:HttpServletRequest ,
			response:HttpServletResponse , wr:Writer ) = {
    val now = new Date
    val content = "Hello, ! Now is: " + now
    val json = new java.util.HashMap[String, String]
    json.put("content", content)
    json
  }
  
    @RequestMapping(Array("", "/json"))
//   @RequestMapping(Array("", "/"))
    def greeting() = {
    val now = new Date
    val content = "Hello, ! Now is: " + now
    val json = new java.util.HashMap[String, String]
    json.put("content", content)
    json
  }
  @RequestMapping(Array("/filter"))
  def filter(model: Model) = {
    model.addAttribute("key", "key的值")
    new ModelAndView("filter")
  }
   @RequestMapping(value = { Array("/home") }, method = Array(RequestMethod.GET))
  def index() = new ModelAndView("/home")

}